package com.huatai.datacenter.utils;

import org.apache.commons.codec.binary.Base64;

/**
 * @author Lion
 * @date 2023/6/15  14:01
 */
public class CryptoUtil {

	/**
	 * @author Lion
	 * @description base64加密
	 * @param  * @param str
	 * @return java.lang.String
	 */
	public static String encode(String str)
	{
		try
		{
			byte[] textByte = str.getBytes("UTF-8");
			return new Base64().encodeToString(textByte);
		}
		catch (Exception e)
		{
		}
		return "";
	}

	/**
	 * @author Lion
	 * @description base64解密
	 * @param  * @param encodedText
	 * @return java.lang.String
	 */
	public static String decode(String encodedText)
	{
		String pass = "";
		try
		{
			Base64 base64 = new Base64();
			pass = new String(base64.decode(encodedText), "UTF-8");
		}
		catch (Exception localException)
		{
		}
		return pass;
	}
}
